import Vue from 'vue'
import Router from 'vue-router'
import Login from './views/login.vue'
import Admin from './views/admin.vue'
import Welcome from './views/admin/welcome.vue'
import Category from './views/admin/category.vue'
import Course from "./views/admin/course.vue"
import Chapter from './views/admin/chapter.vue'
import Section from './views/admin/section.vue'
import Content from './views/admin/content.vue'
import Teacher from "./views/admin/teacher.vue"
import File from "./views/admin/file.vue"
import User from "./views/admin/user.vue"
import Resource from "./views/admin/resource.vue"
import Role from "./views/admin/role.vue"
import Member from "./views/admin/member"
import Sms from "./views/admin/shortMessagingService"

Vue.use(Router);

export default new Router({
    mode: 'history',
    base: process.env.BASE_URL,
    routes: [{
        path: '*',
        redirect: '/login'
    },{
        path: "",
        //凡是路径中域名后面是空字符了都会被重定向到login.vue，*代表任何字符
        redirect: "/login",
    },{
        path: '/login',
        //login.vue的路由，路径中域名后是login都会被导向login.vue页面
        component: Login,
    },{
        path: "/",
        name: "admin",
        component: Admin,
        //meta是一个对象，它的属性可以自定义，使用时直接引用属性名。
        //打开router.js文件按ctrl+F搜索loginRequire使用示例
        meta: {
            loginRequire: true
        },
        children: [{
            //子路由下的path的值不要有/，有/会被认为是根路径，然后导航到了login页面。
            path: "welcome",
            name: "welcome",
            component: Welcome
        }, {
            path: "business/category",
            name: "business/category",
            component: Category,
        }, {
            path: "business/course",
            name: "business/course",
            component: Course,
        }, {
            path: "business/chapter",
            name: "business/chapter",
            component: Chapter
        }, {
            path: "business/section",
            name: "business/section",
            component: Section
        }, {
            path: "business/content",
            name: "business/content",
            component: Content,
        }, {
            path: "business/teacher",
            name: "business/teacher",
            component: Teacher,
        }, {
            path: "business/member",
            name: "business/member",
            component: Member,
        }, {
            path: "business/sms",
            name: "business/sms",
            component: Sms,
        }, {
            path: "file/file",
            name: "file/file",
            component: File,
        }, {
            path: "system/user",
            name: "system/user",
            component: User,
        }, {
            path: "system/resource",
            name: "system/resource",
            component: Resource,
        }, {
            path: "system/role",
            name: "system/role",
            component: Role,
        },]
    },]
});